#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Threading;
using System.Windows.Threading;
using UTable.Input;
using UTable.Input.MultiTouch;
using UTable.Objects;
using UTable.Objects.Controls;

namespace UTable.Objects.Controls
{
	/// <summary>
	/// Interaction logic for UWarnDialog.xaml
	/// </summary>
	public partial class UWarnDialog : UDialog
	{
        public UWarnDialog()
		{
			InitializeComponent();
			this.DataContext = this;
		}

        public UWarnDialog(string msg) : this()
        {
            Message = msg;
        }

		public string Message
		{
			get { return (string)GetValue(MessageProperty); }
			set { SetValue(MessageProperty, value); }
		}

		public static readonly DependencyProperty MessageProperty =
			DependencyProperty.Register("Message", typeof(string), typeof(UWarnDialog), new UIPropertyMetadata(string.Empty));

		private void OkButton_Pressed(object sender, ButtonEventArgs args)
		{
			this.Close();
		}

        //public static void Show(string msg)
        //{
        //    try
        //    {
        //        // Fix: this method can not be invoked in more than one place simultaneously.
        //        Thread t = new Thread(() => ShowMessageThread(msg));
        //        t.SetApartmentState(ApartmentState.STA);
        //        t.IsBackground = true;
        //        t.Start();
        //    }
        //    catch (System.Exception ex)
        //    {
        //        MessageBox.Show(ex.ToString());
        //    }
        //}

        //private static void ShowMessageThread(string msg)
        //{
        //    UWarnDialog dialog;
        //    dialog = new UWarnDialog(msg);
        //    dialog.Open();
        //}
	}
}